﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Congty
{
    public partial class Form1 : Form
    {
        CongTyDataContext db = new CongTyDataContext();
        public Form1()
        {
            InitializeComponent();
        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            
            dataGridView1.DataSource = db.NhanViens.OrderBy(nv => nv.HoTen);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            label1.Text = db.NhanViens.Where(nv => nv.HoTen == textBox1.Text).FirstOrDefault().SDT.ToString();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            NhanVien nv = new NhanVien();
            nv.HoTen = tbhoten.Text;
            nv.DiaChi = tbdiachi.Text;
            nv.SDT = decimal.Parse(tbphone.Text);
            nv.MaNV = "";
            db.NhanViens.InsertOnSubmit(nv);
            db.SubmitChanges();
        }
    }
}
